<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  var arr = function (head, n) {
    let ret = new ListNode(0, head),
      slow = fast = ret;
    while (n--) fast = fast.next;
    if (!fast) return ret.next;
    while (fast.next) {
      fast = fast.next;
      slow = slow.next
    };
    slow.next = slow.next.next;
    return ret.next;
  };
  console.log(arr(head = [1, 2, 3, 4, 5], n = 2));
</script>

</html>